package com.zcxy.web.controller.edu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zcxy.common.annotation.Log;
import com.zcxy.common.core.controller.BaseController;
import com.zcxy.common.core.domain.AjaxResult;
import com.zcxy.common.enums.BusinessType;
import com.zcxy.edu.domain.EduTeacherSmsConfig;
import com.zcxy.edu.service.IEduTeacherSmsConfigService;
import com.zcxy.common.utils.poi.ExcelUtil;
import com.zcxy.common.core.page.TableDataInfo;

/**
 * 短信配置Controller
 *
 * @author ruoyi
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/edu/smsConfig")
public class EduTeacherSmsConfigController extends BaseController
{
    @Autowired
    private IEduTeacherSmsConfigService eduTeacherSmsConfigService;

    /**
     * 查询短信配置列表
     */
    @PreAuthorize("@ss.hasPermi('edu:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduTeacherSmsConfig eduTeacherSmsConfig)
    {
        startPage();
        List<EduTeacherSmsConfig> list = eduTeacherSmsConfigService.selectEduTeacherSmsConfigList(eduTeacherSmsConfig);
        return getDataTable(list);
    }

    /**
     * 导出短信配置列表
     */
    @PreAuthorize("@ss.hasPermi('edu:config:export')")
    @Log(title = "短信配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduTeacherSmsConfig eduTeacherSmsConfig)
    {
        List<EduTeacherSmsConfig> list = eduTeacherSmsConfigService.selectEduTeacherSmsConfigList(eduTeacherSmsConfig);
        ExcelUtil<EduTeacherSmsConfig> util = new ExcelUtil<EduTeacherSmsConfig>(EduTeacherSmsConfig.class);
        util.exportExcel(response, list, "短信配置数据");
    }

    /**
     * 获取短信配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('edu:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eduTeacherSmsConfigService.selectEduTeacherSmsConfigById(id));
    }

    /**
     * 新增短信配置
     */
    @PreAuthorize("@ss.hasPermi('edu:config:add')")
    @Log(title = "短信配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduTeacherSmsConfig eduTeacherSmsConfig)
    {
        return toAjax(eduTeacherSmsConfigService.insertEduTeacherSmsConfig(eduTeacherSmsConfig));
    }

    /**
     * 修改短信配置
     */
    @PreAuthorize("@ss.hasPermi('edu:config:edit')")
    @Log(title = "短信配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduTeacherSmsConfig eduTeacherSmsConfig)
    {
        return toAjax(eduTeacherSmsConfigService.updateEduTeacherSmsConfig(eduTeacherSmsConfig));
    }

    /**
     * 删除短信配置
     */
    @PreAuthorize("@ss.hasPermi('edu:config:remove')")
    @Log(title = "短信配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eduTeacherSmsConfigService.deleteEduTeacherSmsConfigByIds(ids));
    }
}
